home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / linuxdoc-sgml-1.1 / sgmls-1.1 / configure < prev    next >
Encoding:
Text File  |  1995-05-03  |  9.5 KB  |  618 lines

  1. #!/bin/sh
  2. # Generate config.h from unix.cfg.
  3.  
  4. trap 'rm -f doit doit.c doit.o doit.log config.out; exit 1' 1 2 3 15
  5.  
  6. on=
  7. off=
  8. CC=${CC-cc}
  9.  
  10. # Normally we use VARARGS if __STDC__ is not defined.
  11. # Test whether this assumption is wrong.
  12.  
  13. cat >doit.c <<\EOF
  14. #ifdef __STDC__
  15. #include <stdarg.h>
  16. int foo(char *s,...)
  17. {
  18.   va_list ap;
  19.  
  20.   va_start(ap, s);
  21.   va_end(ap);
  22.   return 0;
  23. }
  24. #else
  25. int foo = 0;
  26. #endif
  27. EOF
  28.  
  29. $CC $CFLAGS -c doit.c >/dev/null 2>&1
  30. if test $? -ne 0
  31. then
  32.     on="$on VARARGS"
  33. fi
  34.  
  35. cat >doit.c <<\EOF
  36. #include <stddef.h>
  37. int foo = 0;
  38. EOF
  39.  
  40. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  41. then
  42.     off="$off STDDEF_H_MISSING"
  43. else
  44.     on="$on STDDEF_H_MISSING"
  45. fi
  46.  
  47. cat >doit.c <<\EOF
  48. #include <stdlib.h>
  49. int foo = 0;
  50. EOF
  51.  
  52. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  53. then
  54.     off="$off STDLIB_H_MISSING"
  55. else
  56.     on="$on STDLIB_H_MISSING"
  57. fi
  58.  
  59. cat >doit.c <<\EOF
  60. #include <limits.h>
  61. int foo = 0;
  62. EOF
  63.  
  64. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  65. then
  66.     off="$off LIMITS_H_MISSING"
  67. else
  68.     on="$on LIMITS_H_MISSING"
  69. fi
  70.  
  71. cat >doit.c <<\EOF
  72. #include <vfork.h>
  73. int foo = 0;
  74. EOF
  75.  
  76. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  77. then
  78.     on="$on HAVE_VFORK_H"
  79. else
  80.     off="$off HAVE_VFORK_H"
  81. fi
  82.  
  83. cat >doit.c <<\EOF
  84. #include <unistd.h>
  85. int foo = 0;
  86. EOF
  87.  
  88. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  89. then
  90.     on="$on HAVE_UNISTD_H"
  91. else
  92.     off="$off HAVE_UNISTD_H"
  93. fi
  94.  
  95. cat >doit.c <<\EOF
  96. #include <sys/types.h>
  97. #include <sys/stat.h>
  98. int foo = 0;
  99. EOF
  100.  
  101. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  102. then
  103.     on="$on HAVE_SYS_STAT_H"
  104. else
  105.     off="$off HAVE_SYS_STAT_H"
  106. fi
  107.  
  108. cat >doit.c <<\EOF
  109. /* Exit normally unless we need to use isascii. */
  110.  
  111. #include <ctype.h>
  112. #include <signal.h>
  113.  
  114. static int whoops()
  115. {
  116.   _exit(1);
  117. }
  118.  
  119. main()
  120. {
  121.   int c;
  122. #ifdef isascii
  123. #ifdef SIGSEGV
  124.   signal(SIGSEGV, whoops);
  125. #endif
  126. #ifdef SIGBUS
  127.   signal(SIGBUS, whoops);
  128. #endif
  129. #ifdef SIGIOT
  130.   signal(SIGIOT, whoops);
  131. #endif
  132.  
  133.   for (c = 128; c < 256; c++) {
  134.     if (c == '0' || c == '1' || c == '2' || c == '3' || c == '4' || c == '5'
  135.     || c == '6' || c == '7' || c == '8' || c == '9') {
  136.       if (!isdigit(c) || isalpha(c) || iscntrl(c) || isspace(c) || ispunct(c))
  137.     exit(1);
  138.     }
  139.     else if (isdigit(c))
  140.       exit(1);
  141.     else if (isalpha(c)) {
  142.       if (iscntrl(c) || isspace(c) || ispunct(c)
  143.       || (islower(c) && toupper(c) != c && !isupper(toupper(c)))
  144.       || (isupper(c) && tolower(c) != c && !islower(tolower(c))))
  145.     exit(1);
  146.     }
  147.     else if (islower(c) || isupper(c))
  148.       exit(1);
  149.     else if (iscntrl(c)) {
  150.       if (ispunct(c))
  151.     exit(1);
  152.     }
  153.   }
  154. #endif /* isascii */
  155.   exit(0);
  156. }
  157. EOF
  158.  
  159. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  160. then
  161.     # This tries to find the symbol that looks like the array
  162.     # used by <ctype.h>, and sees if its length appears to be 128
  163.     # rather than 256.
  164.     if test 1 = `(nm -n doit 2>/dev/null) | awk '
  165. BEGIN {
  166.     weight["0"] = 0;
  167.     weight["1"] = 1;
  168.     weight["2"] = 2;
  169.     weight["3"] = 3;
  170.     weight["4"] = 4;
  171.     weight["5"] = 5;
  172.     weight["6"] = 6;
  173.     weight["7"] = 7;
  174.     weight["8"] = 8;
  175.     weight["9"] = 9;
  176.     weight["a"] = weight["A"] = 10;
  177.     weight["b"] = weight["B"] = 11;
  178.     weight["c"] = weight["C"] = 12;
  179.     weight["d"] = weight["D"] = 13;
  180.     weight["e"] = weight["E"] = 14;
  181.     weight["f"] = weight["F"] = 15;
  182. }
  183.  
  184. /^[0-9a-zA-Z]* D .*ctype/ && ctype_nr == 0 {
  185.     ctype_nr = NR;
  186.     addr = 0;
  187.     len = length($1);
  188.     for (i = 1; i <= len; i++)
  189.         addr = addr*16 + weight[substr($1, i, 1)];
  190. }
  191.  
  192. /^[0-9a-zA-Z]* D / && NR == ctype_nr + 1 {
  193.     next_addr = 0;
  194.     len = length($1);
  195.     for (i = 1; i <= len; i++)
  196.         next_addr = next_addr*16 + weight[substr($1, i, 1)];
  197. }
  198.  
  199. END {
  200.     size = next_addr - addr;
  201.     if (size >= 128 && size < 256)
  202.         print "1";
  203.     else
  204.         print "0";
  205. }'`
  206.     then
  207.         on="$on USE_ISASCII"
  208.     else
  209.         if ((yes | man 3 ctype) 2>/dev/null) \
  210.              | sed -e 's/.//g' -e 's/ *$//' -e '/de-$/N' \
  211.                            -e 's/-\n//g' -e '/defined$/N' -e '/only$/N' \
  212.                   -e '/where$/N' -e '/isascii$/N' -e '/is$/N' \
  213.                -e 's/\n/ /g' -e 's/  */ /g' \
  214.              | grep "defined only where isascii is true" >/dev/null
  215.         then
  216.             on="$on USE_ISASCII"
  217.         else
  218.             off="$off USE_ISASCII"
  219.         fi
  220.     fi
  221. else
  222.     on="$on USE_ISASCII"
  223. fi
  224.  
  225. cat >doit.c <<\EOF
  226. main(argc, argv)
  227. int argc;
  228. char **argv;
  229. {
  230.   if (argc == 0)
  231.     remove("foo");  
  232.   exit(0);
  233. }
  234. EOF
  235.  
  236. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  237. then
  238.     off="$off REMOVE_MISSING"
  239. else
  240.     on="$on REMOVE_MISSING"
  241. fi
  242.  
  243. cat >doit.c <<\EOF
  244. main(argc, argv)
  245. int argc;
  246. char **argv;
  247. {
  248.   if (argc == 0)
  249.     getopt(argc, argv, "v");  
  250.   exit(0);
  251. }
  252. EOF
  253.  
  254. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  255. then
  256.     on="$on HAVE_GETOPT"
  257. else
  258.     off="$off HAVE_GETOPT"
  259. fi
  260.  
  261. cat >doit.c <<\EOF
  262. main(argc, argv)
  263. int argc;
  264. char **argv;
  265. {
  266.   if (argc == 0)
  267.     access("foo", 4);
  268.   exit(0);
  269. }
  270. EOF
  271.  
  272. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  273. then
  274.     on="$on HAVE_ACCESS"
  275. else
  276.     off="$off HAVE_ACCESS"
  277. fi
  278.  
  279. cat >doit.c <<\EOF
  280. main(argc, argv)
  281. int argc;
  282. char **argv;
  283. {
  284.   if (argc == 0)
  285.     vfork();
  286.   exit(0);
  287. }
  288. EOF
  289.  
  290. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  291. then
  292.     on="$on HAVE_VFORK"
  293. else
  294.     off="$off HAVE_VFORK"
  295. fi
  296.  
  297. cat >doit.c <<\EOF
  298. main(argc, argv)
  299. int argc;
  300. char **argv;
  301. {
  302.   
  303.   if (argc == 0) {
  304.     int status;
  305.     waitpid(-1, &status, 0);
  306.   }
  307.   exit(0);
  308. }
  309. EOF
  310.  
  311. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  312. then
  313.     on="$on HAVE_WAITPID"
  314. else
  315.     off="$off HAVE_WAITPID"
  316. fi
  317.  
  318. cat >doit.c <<\EOF
  319. #include <string.h>
  320. main(argc, argv)
  321. int argc;
  322. char **argv;
  323. {
  324.   if (argc == 0)
  325.     strerror(0);
  326.   exit(0);
  327. }
  328. EOF
  329.  
  330. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  331. then
  332.     off="$off STRERROR_MISSING"
  333. else
  334.     on="$on STRERROR_MISSING"
  335. fi
  336.  
  337. cat >doit.c <<\EOF
  338. #include <strings.h>
  339. main(argc, argv)
  340. int argc;
  341. char **argv;
  342. {
  343.   if (argc == 0)
  344.     bcopy((char *)0, (char *)0, 0);
  345.   exit(0);
  346. }
  347. EOF
  348.  
  349. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  350. then
  351.     # Only use BSD_STRINGS if ANSI string functions don't work.
  352.     cat >doit.c <<\EOF
  353. #include <string.h>
  354. main(argc, argv)
  355. int argc;
  356. char **argv;
  357. {
  358.   if (argc == 0)
  359.     memcpy((char *)0, (char *)0, 0);
  360.   exit(0);
  361. }
  362. EOF
  363.  
  364.     if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  365.     then
  366.         off="$off BSD_STRINGS"
  367.     else
  368.         on="$on BSD_STRINGS"
  369.     fi
  370. else
  371.     off="$off BSD_STRINGS"
  372. fi
  373.  
  374. cat >doit.c <<\EOF
  375. #include <signal.h>
  376. main(argc, argv)
  377. int argc;
  378. char **argv;
  379. {
  380.   if (argc == 0)
  381.     raise(SIGINT);  
  382.   exit(0);
  383. }
  384. EOF
  385.  
  386. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  387. then
  388.     off="$off RAISE_MISSING"
  389. else
  390.     on="$on RAISE_MISSING"
  391. fi
  392.  
  393. cat >doit.c <<\EOF
  394. #include <stdio.h>
  395. main(argc, argv)
  396. int argc;
  397. char **argv;
  398. {
  399.   if (argc == 0) {
  400.     fpos_t pos;
  401.     fsetpos(stdin, &pos);
  402.     fgetpos(stdin, &pos);
  403.   }  
  404.   exit(0);
  405. }
  406. EOF
  407.  
  408. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  409. then
  410.     off="$off FPOS_MISSING"
  411. else
  412.     on="$on FPOS_MISSING"
  413. fi
  414.  
  415. cat >doit.c <<\EOF
  416. #include <unistd.h>
  417. #include <sys/types.h>
  418. #include <sys/wait.h>
  419.  
  420. main(argc, argv)
  421. int argc;
  422. char **argv;
  423. {
  424.   if (argc == 0) {
  425.     pid_t pid;
  426.     int status;
  427.     long n = sysconf(_SC_OPEN_MAX);
  428.     pid = waitpid(-1, &status, 0);
  429.     WIFSTOPPED(status);
  430.     WIFSIGNALED(status);
  431.     WIFEXITED(status);
  432.     WEXITSTATUS(status);
  433.     WTERMSIG(status);
  434.     WSTOPSIG(status);
  435.   }
  436.   exit(0);
  437. }
  438. EOF
  439.  
  440. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  441. then
  442.     on="$on POSIX"
  443. else
  444.     off="$off POSIX"
  445. fi
  446.  
  447. cat >doit.c <<\EOF
  448. #include <stdio.h>
  449. #include <signal.h>
  450.  
  451. static int whoops()
  452. {
  453.   _exit(1);
  454. }
  455.  
  456. main()
  457. {
  458.   char buf[30];
  459. #ifdef SIGSEGV
  460.   signal(SIGSEGV, whoops);
  461. #endif
  462. #ifdef SIGBUS
  463.   signal(SIGBUS, whoops);
  464. #endif
  465. #ifdef SIGIOT
  466.   signal(SIGIOT, whoops);
  467. #endif
  468.   sprintf(buf, "%2$s%2$s%1$s%1$s", "bar", "foo");
  469.   exit(!!strcmp(buf, "foofoobarbar"));
  470. }
  471. EOF
  472.  
  473. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  474. then
  475.     on="$on HAVE_EXTENDED_PRINTF"
  476. else
  477.     off="$off HAVE_EXTENDED_PRINTF"
  478. fi
  479.  
  480. cat >doit.c <<\EOF
  481. #include <nl_types.h>
  482.  
  483. main(argc, argv)
  484. int argc;
  485. char **argv;
  486. {
  487.   if (argc == 0) {
  488.     nl_catd d = catopen("foo", 0);
  489.     catgets(d, 1, 1, "default");
  490.     catclose(d);
  491.   }
  492.   exit(0);
  493. }
  494. EOF
  495.  
  496. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  497. then
  498.     on="$on HAVE_CAT"
  499. else
  500.     off="$off HAVE_CAT"
  501. fi
  502.  
  503. cat >doit.c <<\EOF
  504. #include <limits.h>
  505.  
  506. char c = UCHAR_MAX;
  507.  
  508. main(argc, argv)
  509. int argc;
  510. char **argv;
  511. {
  512. #if CHAR_MIN < 0
  513.   exit(!(c < 0));
  514. #else
  515.   exit(!(c > 0));
  516. #endif
  517. }
  518. EOF
  519.  
  520. if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  521. then
  522.     char_signed=
  523. else
  524.     cat >doit.c <<\EOF
  525. main()
  526. {
  527.   int i;
  528.  
  529.   for (i = 0; i < 512; i++) {
  530.     char c = (char)i;
  531.     if (c < 0)
  532.     exit(1);
  533.   }
  534.   exit(0);
  535. }
  536. EOF
  537.  
  538.     if $CC $CFLAGS -o doit doit.c $LIBS >/dev/null 2>&1 && ./doit 2>/dev/null
  539.     then
  540.         char_signed=0
  541.     else
  542.         char_signed=1
  543.     fi
  544. fi
  545.  
  546. cat >doit.c <<\EOF
  547.  
  548. typedef void VOID;
  549.  
  550. extern VOID bar();
  551.  
  552. VOID foo()
  553. {
  554. }
  555. EOF
  556.  
  557. if $CC $CFLAGS -c doit.c >/dev/null 2>&1
  558. then
  559.     void_ret=void
  560. else
  561.     void_ret=int
  562. fi
  563.  
  564.  
  565. cat >doit.c <<\EOF
  566.  
  567. void *foo()
  568. {
  569.   static char *buf;
  570.   return buf;
  571. }
  572. EOF
  573.  
  574. if $CC $CFLAGS -c doit.c >doit.log 2>&1
  575. then
  576.     if test -s doit.log
  577.     then
  578.         void_star="char \*"
  579.     else
  580.         void_star="void \*"
  581.     fi
  582.  
  583. else
  584.     void_star="char \*"
  585. fi
  586.  
  587. edit=
  588.  
  589. rm -f doit.c doit doit.log doit.o
  590.  
  591. for var in $on
  592. do
  593.     edit="$edit -e 's;^/\\* *\\(#define $var [^/]*\\) *\\*/;\\1;'"
  594. done
  595. for var in $off
  596. do
  597.     edit="$edit -e 's;^#define $var [^/]*;/* & */;'"
  598. done
  599.  
  600. if test -n "$char_signed"
  601. then
  602.     edit="$edit -e 's;^/\\* *\\(#define CHAR_SIGNED $char_signed\\) *\\*/;\\1;'"
  603. fi
  604.  
  605. edit="$edit -e 's/^typedef .*VOID;/typedef $void_ret VOID;/'"
  606. edit="$edit -e 's/^typedef .*UNIV;/typedef ${void_star}UNIV;/'"
  607.  
  608. if test "X$(PREFIX)" != "X/usr/local"
  609. then
  610.     edit="$edit -e '/DEFAULT_PATH/s;/usr/local;$PREFIX;g'"
  611. fi
  612.  
  613. eval sed $edit unix.cfg ">config.out"
  614.  
  615. mv config.out config.h
  616.  
  617. exit 0
  618.